home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / UTILITIE / CPU_MEMO / 3468.ZIP / POPUP.ZIP / SCREENIO.ASM < prev    next >
Assembly Source File  |  1988-06-30  |  4KB  |  170 lines

  1. ;*****************************************************************************
  2. ;* Module SCREENIO.ASM - Contains simple functions for writing directly to   *
  3. ;* a monochrome, cga, ega, vga etc display. For use with "windows" module.   *
  4. ;*****************************************************************************
  5.  
  6. include CLINK.INC
  7.  
  8. .DATA
  9.  
  10. extrn   _DisplaySegment:word
  11. extrn   _DisplayStatus:word
  12.  
  13. .CODE 
  14.  
  15. ;=================================================================
  16. ;
  17. ;       void WriteScreen(row,col,buffer,words)
  18. ;       int row;        row coordinate to print to
  19. ;       int col;        col coordinate to print to
  20. ;       char *buffer;   address of buffer to print to screen
  21. ;       int words;      number of char/attrib pairs to put
  22. ;
  23. ;=================================================================
  24.  
  25. PUBLIC          _WriteScreen
  26. STARTPROC       _WriteScreen
  27. DEFARGS         row, WORD, col, WORD, buffer, PTR, words, WORD
  28.  
  29.         push    es
  30.         push    ds
  31.         push    si
  32.         push    di
  33.  
  34.         mov     dx,_DisplaySegment
  35.         mov     es,dx                   ; screen address in ES
  36.  
  37.         MOVARG  ax,row
  38.         mov     cl,80                   ; get ready to multiply for line offset
  39.         mul     cl
  40.         mov     cx,2                    ; get ready to multiply char & attrib
  41.         mul     cx
  42.  
  43.         push    ax
  44.         MOVARG  ax,col
  45.         mov     cl,2
  46.         mul     cl
  47.         mov     cx,ax
  48.         pop     ax
  49.  
  50.         add     ax,cx
  51.         mov     di,ax                   ; screen offset in DI
  52.         mov     dx,_DisplayStatus
  53.         LDPTR   ds, si, buffer
  54.         MOVARG  cx, words
  55.  
  56. nxtchr:
  57.  
  58.         cmp     cx,0
  59.         jbe     pdone                   ; go if byte count <= 0
  60.         mov     bx,[si]                 ;char and attrib in BX  
  61.  
  62. pwait_lo1:
  63.  
  64.         in      al,dx
  65.         test    al,1
  66.         jnz     pwait_lo1
  67.  
  68. pwait_hi1:
  69.  
  70.         in      al,dx
  71.         test    al,1
  72.         jz      pwait_hi1
  73.  
  74. pputit:
  75.  
  76.         mov     es:[di],bx              ;
  77.         inc     si
  78.         inc     si
  79.         inc     di
  80.         inc     di
  81.         dec     cx
  82.         jmp     nxtchr
  83.  
  84. pdone:
  85.  
  86.         pop     di
  87.         pop     si
  88.         pop     ds
  89.         pop     es
  90.         RETPROC
  91.  
  92. _WriteScreen    endp
  93.  
  94.  
  95. ;=================================================================
  96. ;
  97. ;       void ReadScreen(row,col,buffer,words)
  98. ;       int row;        row coordinate to get from
  99. ;       int col;        col coordinate to get from
  100. ;       char *buffer;   address of buffer to put screen info into
  101. ;       int words;      number of char/attrib pairs to get
  102. ;
  103. ;=================================================================
  104.  
  105. PUBLIC          _ReadScreen
  106. STARTPROC       _ReadScreen
  107. DEFARGS         row, WORD, col, WORD, buffer, PTR, words, WORD
  108.  
  109.         push    es
  110.         push    ds
  111.         push    si
  112.         push    di
  113.  
  114.         mov     dx,_DisplaySegment
  115.         mov     es,dx
  116.  
  117.         MOVARG  ax,row
  118.         mov     cl,80                   ; get ready to multiply for line offset
  119.         mul     cl
  120.         mov     cx,2                    ; get ready to multiply char & attrib
  121.         mul     cx
  122.  
  123.         push    ax
  124.         MOVARG  ax,col
  125.         mov     cl,2
  126.         mul     cl
  127.         mov     cx,ax
  128.         pop     ax
  129.  
  130.         add     ax,cx
  131.         mov     si,ax                   ; screen offset in SI
  132.         mov     dx,_DisplayStatus
  133.         LDPTR   ds, di, buffer
  134.         MOVARG  cx, words
  135.  
  136. gwait_lo1:
  137.  
  138.         in      al,dx
  139.         test    al,1
  140.         jnz     gwait_lo1
  141.  
  142. gwait_hi1:
  143.  
  144.         in      al,dx
  145.         test    al,1
  146.         jz      gwait_hi1
  147.  
  148. gputit:
  149.  
  150.         mov     bx,es:[si]              ; char from screen to BL
  151.         inc     si                      ; point to attrib byte
  152.         inc     si
  153.         mov     [di],bx                 ;put char+attrib in buffer      
  154.         inc     di                      ;/_____ increment
  155.         inc     di                      ;\     screen pointer
  156.         dec     cx                      ; 1 less word to move
  157.         cmp     cx,0
  158.         jnz     gwait_lo1
  159.  
  160.         pop     di
  161.         pop     si
  162.         pop     ds
  163.         pop     es
  164.         RETPROC
  165.  
  166. _ReadScreen     endp
  167.  
  168. END
  169.  
  170.